package com.hitales.liteflow.liteflowdemo.contextdemo;

import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;

@LiteflowComponent("contexta")
public class AComponent extends NodeComponent {

    @Override
    public void process() {
        Object requestData = this.getRequestData();
        // 获取原始请求数据
        System.out.println("流程的初始化数据是"+requestData);
        //获取流程的名称
        String chainName = this.getChainName();
        System.out.println("组件的名称"+chainName);
        // 获取组件ID
        String chainId = this.getChainId();
        System.out.println("chain的ID"+chainId);
        // 获取组件ID
        String nodeId = this.getNodeId();
        System.out.println("节点的ID"+nodeId);
        // 获取组件别名
        String name = this.getName();
        System.out.println("组件的别名"+name);
        // 获取上下文
        CustomContext context = this.getContextBean(CustomContext.class);

        // 写入数据
        context.setUserId("U12345");
        context.setAge(30);

        System.out.println("A组件写入数据: userId=U12345, age=30");
    }
}

